import path from 'path'
export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  // 定制化顶部loading加载  在user/index.vue下使用loading
  loading: {
    color: 'blue',
    height: '2px'
  },
  head: {
    title: 'nuxtapps',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],  
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },
  router:{
    // 中间件 每当触发路由，在进入页面之前执行stats.js下的自定义函数
    // 现在，stats 中间件将在每个路由改变时被调用
    // 您也可以将 middleware 添加到指定的布局或者页面例如：users.vue
    // middleware: 'stats',
    extendRoutes (routes, resolve) {
      // 命名视图 在vue路由中也存在此机制
      const index = routes.findIndex(route => route.name === 'main')
      routes[index] = {
        ...routes[index],
        components: {
          default: routes[index].component,  // 默认视图
          top: './components/mainTop.vue'  // 命名视图
        },
        chunkNames: {
          top: './components/mainTop'
        }
      }
    }
  },
  // dir 程序目录 默认如下
  dir:{
    assets: 'assets',
    layouts: 'layouts',
    middleware: 'middleware',
    pages: 'pages',
    static: 'static',
    store: 'store'
  },
  // 环境变量 设置客户端与服务器端共可使用的环境变量
  env: {
    baseUrl: process.env.BASE_URL || 'http://localhost:3000'
  },
  //全局样式
  css: ['./node_modules/element-ui/lib/theme-chalk/index.css','./styles/commit.css'],

  //插件机制
  plugins: [{ src: '~/plugins/main.ts', ssr: true },
  { src: './plugins/route', ssr: true }],

  //自动导入组件，无需注册
  components: true,
  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    // https://go.nuxtjs.dev/stylelint
    '@nuxtjs/stylelint-module',
  ],
  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/bootstrap
    "@nuxtjs/axios"
  ],
  axios:{
    proxy:true
  },
  proxy:{
    "/api":"http://localhost:9653"
  },
  cli: {
    bannerColor: 'yellow'
  }, 
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {},
}
